package com.ynny.usermanager.controller;

import com.ynny.usermanager.entity.R;
import com.ynny.usermanager.entity.User;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/list")
    public R list(){

        //模拟一个集合 数据
        ArrayList<User> list = new ArrayList<>();
        list.add(new User(1,"张三","123",2));
        list.add(new User(2,"张三2","123",2));
        list.add(new User(3,"张三3","123",2));
        list.add(new User(4,"张三4","123",2));
        list.add(new User(5,"张三5","123",2));
        list.add(new User(6,"张三6","123",2));

        return R.ok(list);
    }



    @PostMapping("/add")
    public R addUser(@RequestBody User user){

        System.out.println("新增的用户为:" + user);
        return R.ok(null);
    }
}
